<?php
include_once("codelibrary/inc/variables.php");
include_once("session.php");
include_once("codelibrary/inc/functions.php");


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
$interval = 15;

$timefrom = "08:00";
$typefrom = "am";

$timeto = "05:00";
$typeto = "pm";

if($typefrom=="am")
{
     $timefrom_array = explode(":",$timefrom);
     $hourfrom = $timefrom_array[0];
	 $minutefrom = $timefrom_array[1];
	 $secondfrom = 0;
}

if($typeto=="pm")
{
     $timeto_array = explode(":",$timeto);
     $hourto = 12 + $timeto_array[0];
	 $minuteto = $timeto_array[1];
	 $secondto = 0;
}

$start_time = mktime($hourfrom, $minutefrom, $secondfrom, 1, 1, 1970);
$end_time = mktime($hourto, $minuteto, $secondto, 1, 1, 1970);
$interval = 60*$interval;

$num_intervals = floor(($end_time - $start_time) / $interval);

//Build a list of times.
$buffer_time = $start_time;
$times[$i]['end'] = $start_time;

echo $iso_starttime = date('h:i:s a', $start_time);
echo "<br/>";
for($i = 0; $i < $num_intervals; $i++) 
{
        if(($i+1)!=$num_intervals)
		{
				$times[$i]['end'] = $buffer_time += $interval;
				
				$iso_timeto[$i]['end'] = date('h:i:s a', $times[$i]['end']);
			
	    }
		print_r($iso_timeto[$i]['end']);
        echo "<br/>";
}

?>
</body>
</html>
